#pragma once
#include "util/json_util.hpp"

class Log{
public:
    static void log(const FileHeader &fileHeader,std::string value = ""){
        nlohmann::json d{};
        to_json(d,fileHeader);
        std::cout << "log FileHeader json: " << value+" " << d.dump(4) << std::endl;
    }
    static void log(const PageHead &pageHead,std::string value = ""){
        nlohmann::json d{};
        to_json(d,pageHead);
        std::cout << "log PageHead json: " << value+" " << d.dump(4) << std::endl;
    }
    static void log(const std::vector<SqlFilter> &sqlFilter,std::string value = ""){
//        nlohmann::json d{};
//        to_json(d,sqlFilter);
//        std::cout << "log SqlFilter json: " << value+" " << d.dump(4) << std::endl;
        nlohmann::json j{};
        to_json_vector<SqlFilter>(j,sqlFilter);
        std::cout << "log SqlFilter json: " << value+" " << j.dump(4) << std::endl;
    }
    static void log(const std::vector<UpdateSetItem> &updateSet,std::string value = ""){
        nlohmann::json j{};
        to_json_vector<UpdateSetItem>(j,updateSet);
        std::cout << "log UpdateSetItem json: " << value+" " << j.dump(4) << std::endl;
    }
    static void log(const std::vector<Cell> &cells, const std::vector<FieldInfo> &fieldList,std::string value = ""){
        nlohmann::json j{};
        to_json(j,cells,fieldList);
        std::cout << "log cells json: " << value+" " << j.dump(4) << std::endl;
    }
    static void log(const std::vector<FieldInfo> &fieldList,std::string value = ""){
//        for (FieldInfo f:fieldList) {
//            std::cout << "type " << value+" " << (int)f.type << std::endl;
//            std::cout << "name " << value+" " << f.name << std::endl;
//            std::cout << "isPrimary " << value+" " << f.isPrimary << std::endl;
//            std::cout << "autoIncrement " << value+" " << f.autoIncrement << std::endl;
//        }
        nlohmann::json j{};
        to_json_vector<FieldInfo>(j,fieldList);
        std::cout << "log FieldInfo json: " << value+" " << j.dump(4) << std::endl;
    }

    static void log(const std::vector<uint32_t> intArray){
        std::cout << "[ " << std::endl;
        for (int i = 0; i < intArray.size(); ++i) {
            std::cout << i << " ..... " << intArray.at(i) << std::endl;
        }
        std::cout << "] " << std::endl;
    }


    static void log(const std::string& text){
        std::cout << text << std::endl;
    }
};